<template>
    <view class="pop-store-container">
        <header-bar :config="config" @onBack="onBack"></header-bar>
        <!-- <view class="pop-head-tab">
			<iconsfont customIcons="icon-dagou  left icon-box-none" size="40" @click="goback"></iconsfont>
			<text class="head-tab-name">{{headTitle}}</text>
		</view> -->
        <mescroll-uni
            class="store-list"
            ref="mescrollRef"
            @init="mescrollInit"
            :height="liheight"
            style="width: 100vw"
            :down="downOption"
            :up="upOption"
            @down="downCallback"
            @up="getData">
            <view class="container">
                <depository-item
                    v-for="(item, index) in list"
                    :key="index"
                    :data="item"
                    @chooseDepository="chooseDepository(item.id)"></depository-item>
                <!-- <depository-item @chooseDepository="chooseDepository"></depository-item> -->
            </view>
        </mescroll-uni>
    </view>
</template>
<script>
import depositoryItem from "@/pages_tms/components/order/depository-item.vue"
import { PageRepository } from "@/pages_tms/service/logistics.js"
export default {
    components: { depositoryItem },
    props: {
        config: {
            type: Object,
            default: () => {},
        },
        liheight: {
            type: String,
            default: "auto",
        },
        headTitle: {
            type: String,
            default: "请选择仓库",
        },
        state: {
            type: Number,
            default: 0,
        },
    },
    data() {
        return {
            list: [],
        }
    },
    watch: {
        state(newV, oldV) {
            console.log("00000")
            console.log(newV)
        },
    },
    mounted() {
        this.mescroll.resetUpScroll()
    },
    methods: {
        goback() {
            this.$emit("goback")
        },
        onBack() {
            this.$emit("onBack")
        },
        chooseDepository(id) {
            // storage.setCache("currentStore",data)
            this.$emit("chooseDepository", id)
        },
        getData(page) {
            let param = {}
            param.pageSize = page.size
            param.pageIndex = page.num
            param.operateType = this.state
            PageRepository(param)
                .then((res) => {
                    if (res.State) {
                        console.log(res)
                        this.mescroll.endByPage(res.Data.length, res.TotalAmout)
                        if (page.num == 1) {
                            this.list = []
                        }
                        this.list = this.list.concat(res.Data)
                    }
                })
                .catch(() => {
                    //联网失败, 结束加载
                    this.mescroll.endErr()
                })
        },
    },
}
</script>

<style lang="scss" scoped>
.container {
    padding: $app-page-padding;
}
// 门店列表弹窗
.pop-store-container {
    position: relative;
    background: $uni-bg-color-grey;
    .pop-head-tab {
        height: 88rpx;
        position: relative;
        text-align: center;
        background: $color-white;
        .left {
            position: absolute;
            top: 22rpx;
            left: 24rpx;
        }
        .head-tab-name {
            font-size: $font-size-32;
            line-height: 88rpx;
        }
    }
}
</style>
